package com.app.newiptv.helper;


import com.app.newiptv.bean.LiveListBean;
import com.app.newiptv.bean.RequestDto;
import com.app.newiptv.callback.IRequestCallback;
import com.app.newiptv.callback.IRequestLisenter;
import com.app.newiptv.utils.OkGoUtil;

/**
 * Created by Shinelon on 2017/11/5.
 */

public class LiveListHelper {
    private IRequestCallback callback;

    public LiveListHelper() {

    }

    public void setCallback(IRequestCallback callback) {
        this.callback = callback;
    }

    public void loadLiveListData(String url) {
        OkGoUtil<LiveListBean> okGoUtil = new OkGoUtil<LiveListBean>(LiveListBean.class, OkGoUtil.TYPE_ARRAY, new IRequestLisenter() {
            @Override
            public void onSuccessData(RequestDto dto) {
                if (dto != null && callback != null && dto.getList() != null) {
                    callback.onLoadComplete("", 0, dto.getList().size(), dto.getList());
                }
            }

            @Override
            public void onErrer(int code, String errMsg) {
                if (callback != null) {
                    callback.onFailed(code + "", errMsg);
                }
            }
        });
        okGoUtil.requestGet(url);
    }
}
